cmake_minimum_required(VERSION 3.10)

project(gpxtools)

find_package(EXPAT REQUIRED)

include_directories (. ${EXPAT_INCLUDE_DIRS})

if(CYGWIN)
  add_definitions(-D_XOPEN_SOURCE=700)
endif()

add_executable(gpxls gpxls.cpp Arguments.cpp Algorithm.cpp XMLParser.cpp)
target_link_libraries(gpxls ${EXPAT_LIBRARIES})
install(TARGETS gpxls RUNTIME DESTINATION bin)

add_executable(gpxjson gpxjson.cpp Arguments.cpp Algorithm.cpp XMLParser.cpp)
target_link_libraries(gpxjson ${EXPAT_LIBRARIES})
install(TARGETS gpxjson RUNTIME DESTINATION bin)

add_executable(gpxplot gpxplot.cpp Arguments.cpp Algorithm.cpp XMLParser.cpp)
target_link_libraries(gpxplot ${EXPAT_LIBRARIES})
install(TARGETS gpxplot RUNTIME DESTINATION bin)

add_executable(gpxcoord gpxcoord.cpp Arguments.cpp)
target_link_libraries(gpxcoord)
install(TARGETS gpxcoord RUNTIME DESTINATION bin)

add_executable(gpxrm gpxrm.cpp Arguments.cpp XMLRawParser.cpp)
target_link_libraries(gpxrm ${EXPAT_LIBRARIES})
install(TARGETS gpxrm RUNTIME DESTINATION bin)

add_executable(gpxsplit gpxsplit.cpp Arguments.cpp Algorithm.cpp XMLRawParser.cpp)
target_link_libraries(gpxsplit ${EXPAT_LIBRARIES})
install(TARGETS gpxsplit RUNTIME DESTINATION bin)

add_executable(gpxsim gpxsim.cpp Arguments.cpp Algorithm.cpp XMLRawParser.cpp)
target_link_libraries(gpxsim ${EXPAT_LIBRARIES})
install(TARGETS gpxsim RUNTIME DESTINATION bin)

add_executable(gpxcat gpxcat.cpp Arguments.cpp Algorithm.cpp XMLRawParser.cpp)
target_link_libraries(gpxcat ${EXPAT_LIBRARIES})
install(TARGETS gpxcat RUNTIME DESTINATION bin)

add_executable(gpxosm gpxosm.cpp Arguments.cpp Algorithm.cpp XMLParser.cpp)
target_link_libraries(gpxosm ${EXPAT_LIBRARIES})
install(TARGETS gpxosm RUNTIME DESTINATION bin)

add_executable(gpxgeotag gpxgeotag.cpp Arguments.cpp XMLParser.cpp)
target_link_libraries(gpxgeotag ${EXPAT_LIBRARIES})
install(TARGETS gpxgeotag RUNTIME DESTINATION bin)

add_executable(gpxpath gpxpath.cpp Arguments.cpp XMLRawParser.cpp)
target_link_libraries(gpxpath ${EXPAT_LIBRARIES})
install(TARGETS gpxpath RUNTIME DESTINATION bin)

add_executable(gpxfetch gpxfetch.cpp Arguments.cpp XMLRawParser.cpp)
target_link_libraries(gpxfetch ${EXPAT_LIBRARIES})
install(TARGETS gpxfetch RUNTIME DESTINATION bin)

add_executable(gpxwind gpxwind.cpp Arguments.cpp Algorithm.cpp XMLParser.cpp)
target_link_libraries(gpxwind ${EXPAT_LIBRARIES})
install(TARGETS gpxwind RUNTIME DESTINATION bin)

CONFIGURE_FILE(
  "${CMAKE_SOURCE_DIR}/cmake_uninstall.cmake.in"
  "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
  IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
  "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")
